//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

#include "UI/Types/Types.h"

namespace Engine
{
namespace UI
{

	//
	// Action
	//

	struct UIAction
	{
	// types
	public:
		typedef delegate< void (Widget *) >		callback_t;


	// variables
	private:
		callback_t		_callback;


	// methods
	public:
		UIAction ()
		{}


		UIAction (const callback_t &cb)
		{
			Bind( cb );
		}


		void Bind (const callback_t &cb)
		{
			_callback = cb;
		}


		void Reset ()
		{
			_callback = callback_t();
		}


		bool Empty () const
		{
			return _callback.IsValid();
		}


		void Call (Widget *widget) const
		{
			_callback.SafeCall( widget );
		}


		bool operator == (const UIAction &right) const
		{
			return _callback == right._callback;
		}


		bool operator != (const UIAction &right) const
		{
			return not ( *this == right );
		}


	private:
		static void _DummyCallback (Widget *)
		{
			//WARNING( "Callback is undefined!" );
		}
	};


	typedef Ptr< UIAction >		UIActionPtr;

	
}	// UI
}	// Engine